<template>
  <div>
    <el-form ref="form" :model="form" label-width="150px">
      <el-form-item label="证书名称">
        <el-input class="w500" v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="证书价格">
        <el-input class="w500" v-model="form.certificate_price"></el-input>
      </el-form-item>
      <el-form-item label="证书编号">
        <el-input class="w500" v-model="form.product_code"></el-input>
      </el-form-item>
      <el-form-item label="证书所有人账号">
        <el-input class="w500" v-model="form.user_info.name"></el-input>
      </el-form-item>
      <el-form-item label="证书类型">
        <el-input class="w500" v-model="form.type_text"></el-input>
      </el-form-item>
      <el-form-item label="商品封面图">
        <img v-bind:src="form.goods_info.profile_pic" alt="" width="150" height="150">
      </el-form-item>
      <el-form-item label="商品名称">
        <el-input class="w500" v-model="form.goods_info.title"></el-input>
      </el-form-item>
      <el-form-item label="商品所属分类">
        <el-input class="w500" v-model="form.goods_info.cate_name"></el-input>
      </el-form-item>
      <el-form-item label="艺术品编号">
        <el-input class="w500" v-model="form.goods_info.product_code"></el-input>
      </el-form-item>
      <el-form-item label="艺术家账号">
        <el-input class="w500" v-model="form.goods_info.goods_belonger_name"></el-input>
      </el-form-item>
      <el-form-item label="收益结束时间(天)">
        <el-input class="w500" v-model="form.goods_info.pick_up_time"></el-input>
      </el-form-item>
      <el-form-item label="最早提货时间(天)">
        <el-input class="w500" v-model="form.goods_info.start_delivery_time"></el-input>
      </el-form-item>
      <el-form-item label="最晚交货时间(天)">
        <el-input class="w500" v-model="form.goods_info.end_delivery_time"></el-input>
      </el-form-item>
      <el-form-item label="证书生成时间">
        <el-input class="w500" v-model="form.create_time"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="goBack">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import { mapState } from 'vuex'

  export default {
    data: function () {
      return {
        imgs_url: []
      }
    },
    computed: {
      ...mapState({
        form: state => state.certificate.certificateInfo
      })
    },
    async created () {
      await this.certificateInfo()
      if (this.form.pay_method !== 'currency') {
        this.form.certificate_price = this.form.certificate_price / 100
      }
    },
    methods: {
      async certificateInfo () {
        let payload = {
          id: this.$route.params.id
        }
        await this.$store.dispatch('certificate/certificateInfo', payload)
      },
      goBack () {
        this.$router.go(-1)
      }
    }
  }
</script>
